# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.CloudErrorReporting.V1beta1.Model.ErrorContext do
  @moduledoc """
  A description of the context in which an error occurred. This data should be provided by the application when reporting an error, unless the error report has been generated automatically from Google App Engine logs.

  ## Attributes

  *   `httpRequest` (*type:* `GoogleApi.CloudErrorReporting.V1beta1.Model.HttpRequestContext.t`, *default:* `nil`) - The HTTP request which was processed when the error was triggered.
  *   `reportLocation` (*type:* `GoogleApi.CloudErrorReporting.V1beta1.Model.SourceLocation.t`, *default:* `nil`) - The location in the source code where the decision was made to report the error, usually the place where it was logged. For a logged exception this would be the source line where the exception is logged, usually close to the place where it was caught.
  *   `sourceReferences` (*type:* `list(GoogleApi.CloudErrorReporting.V1beta1.Model.SourceReference.t)`, *default:* `nil`) - Source code that was used to build the executable which has caused the given error message.
  *   `user` (*type:* `String.t`, *default:* `nil`) - The user who caused or was affected by the crash. This can be a user ID, an email address, or an arbitrary token that uniquely identifies the user. When sending an error report, leave this field empty if the user was not logged in. In this case the Error Reporting system will use other data, such as remote IP address, to distinguish affected users. See `affected_users_count` in `ErrorGroupStats`.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :httpRequest =>
            GoogleApi.CloudErrorReporting.V1beta1.Model.HttpRequestContext.t() | nil,
          :reportLocation => GoogleApi.CloudErrorReporting.V1beta1.Model.SourceLocation.t() | nil,
          :sourceReferences =>
            list(GoogleApi.CloudErrorReporting.V1beta1.Model.SourceReference.t()) | nil,
          :user => String.t() | nil
        }

  field(:httpRequest, as: GoogleApi.CloudErrorReporting.V1beta1.Model.HttpRequestContext)
  field(:reportLocation, as: GoogleApi.CloudErrorReporting.V1beta1.Model.SourceLocation)

  field(:sourceReferences,
    as: GoogleApi.CloudErrorReporting.V1beta1.Model.SourceReference,
    type: :list
  )

  field(:user)
end

defimpl Poison.Decoder, for: GoogleApi.CloudErrorReporting.V1beta1.Model.ErrorContext do
  def decode(value, options) do
    GoogleApi.CloudErrorReporting.V1beta1.Model.ErrorContext.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.CloudErrorReporting.V1beta1.Model.ErrorContext do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
